Page({
  // https://wx.maoyan.com/hostproxy/mmcs/cinema/v1/select/cinemas.json?
  // cityId=1&limit=12&offset=0&channelId=70001&brandId=-1&areaId=-1&districtId=-1&lineId=-1&stationId=-1&hallType=-1&serviceId=-1&lng=116.39732&lat=39.908596
  onLoad: function () {
    let app = getApp()
    let _this = this
    app.getLocation(function (locate,latitude,longitude) {
      // console.log(locate)
      _this.setData({
        locate:locate,
        latitude: latitude,
        longitude: longitude
      })

      wx.request({
        url: 'https://wx.maoyan.com/hostproxy/dianying/cities.json',
        method: 'get',
        success: function (res) {
          // console.log(res.data.cts)
          var val = res.data.cts
          var cityId
          val.forEach(ele => {
            if (ele.nm == locate) {
              cityId =  ele.id
            }
          })
          // console.log(cityId)
          wx.request({
            url: 'https://wx.maoyan.com/hostproxy/mmcs/cinema/v1/select/cinemas.json',
            data: {
              cityId: cityId,
              limit: 12,
              offset: 0,
              lng: longitude,
              lat: latitude
            },
            success: function(res) {
              // console.log(res)
              _this.setData({
                items: res.data.data.cinemas
              })
            }
          })
        }
      })
    })
  },
  data: {
    items: []
  } 
})